- @pagetitle = "Group #{@group}"

.card
  %div
    %ul.card-header.nav.nav-tabs.pt-2.px-3.pb-0.flex-nowrap.collapsible{ role: 'tablist' }
      %li.nav-item
        %a.nav-link.text-nowrap#group-members-tab{ aria: { controls: 'group-members' },
          data: { 'bs-toggle': 'tab' }, href: '#group-members', role: 'tab' }
          Group Members
          %span.badge.text-bg-primary
            = @group.users.size
      - if Flipper.enabled?(:request_index, User.session)
        %li.nav-item
          = link_to(group_requests_path(@group, state: %w[new review]), class: 'nav-link', title: 'Requests') do
            Group Requests
            %span.badge.text-bg-primary
              = @group.requests.count
      - else
        %li.nav-item
          %a.nav-link.text-nowrap#reviews-in-tab{ aria: { controls: 'reviews-in', selected: 'true' },
          data: { 'bs-toggle': 'tab' }, href: '#reviews-in', role: 'tab' }
            Incoming Reviews
            %span.badge.text-bg-primary
              = @group.involved_reviews.size
        %li.nav-item
          %a.nav-link.text-nowrap#requests-in-tab{ aria: { controls: 'requests-in' }, data: { 'bs-toggle': 'tab' },
                                                   href: '#requests-in', role: 'tab' }
            Incoming Requests
            %span.badge.text-bg-primary
              = @group.incoming_requests.size
        %li.nav-item
          %a.nav-link.text-nowrap#all-requests-tab{ aria: { controls: 'all-requests' }, data: { 'bs-toggle': 'tab' }, href: '#all-requests',
                                                    role: 'tab' }
            All Requests
            %span.badge.text-bg-primary
              = @group.all_requests_count
      %li.nav-item.dropdown
        %a.nav-link.dropdown-toggle{ href: '#', 'data-bs-toggle': 'dropdown', role: 'button', 'aria-expanded': 'false', 'aria-haspopup': 'true' }
        .dropdown-menu.dropdown-menu-end

  .card-body
    .tab-content
      .tab-pane#group-members{ aria: { controls: 'group-members' }, role: 'tabpanel' }
        %h3
          Group Members
        = render(partial: 'group_members', locals: { group: @group })

      - unless Flipper.enabled?(:request_index, User.session)
        .tab-pane#reviews-in{ aria: { controls: 'reviews-in' }, role: 'tabpanel' }
          %h3 Incoming Reviews
          = render(partial: 'webui/shared/requests_table', locals: { id: 'reviews_in_table', source_url: group_requests_path(@group) })

        .tab-pane#requests-in{ aria: { controls: 'requests-in' }, role: 'tabpanel' }
          %h3 Incoming Requests
          = render(partial: 'webui/shared/requests_table', locals: { id: 'requests_in_table', source_url: group_requests_path(@group) })

        .tab-pane#all-requests{ aria: { controls: 'all-requests' }, role: 'tabpanel' }
          %h3 All Requests
          = render(partial: 'webui/shared/requests_table', locals: { id: 'all_requests_table', source_url: group_requests_path(@group) })
